#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>

using namespace std;


double getNumber(const string& prompt) {
    string line;
    double num;
    while (true) {
        cout << prompt;
        getline(cin, line);
        istringstream iss(line);
        // bug but it simliar without inflution 
        if (iss >> num) {
            char remaining;
            if (iss >> remaining) {
                cout << " Please enter  only one number." << endl;
            } else {
                return num;
            }
        } else {
            cout << "Please enter a valid number." << endl;
        }
    }
}


int getOperation() {
    string line;
    int choice;
    while (true) {
        cout << "Operations:\n1. Add\n2. Subtract\n3. Multiply\n4. Divide\nChoose operation: ";
        getline(cin, line);
        istringstream iss(line);
        if (iss >> choice) {
            char remaining;
            if (iss >> remaining) {
                cout << " Please enter only one number ." << endl;
            } else if (choice < 1 or choice > 4) {
                cout << "Please enter a number between 1 and 4." << endl;
            } else {
                return choice;
            }
        } else {
            cout << "Please enter a valid number." << endl;
        }
    }
}

int main() {
    double num1 = getNumber("Enter first number: ");
    double num2 = getNumber("Enter second number: ");
    int op = getOperation();

    double result;
    bool error = false;

    switch (op) {
        case 1:
            result = num1 + num2;
            break;
        case 2:
            result = num1 - num2;
            break;
        case 3:
            result = num1 * num2;
            break;
        case 4:
            if (num2 == 0) {
                cout << "Division by zero is not allowed." << endl;
                error = true;
            } else {
                result = num1 / num2;
            }
            break;
    }

    if (!error) {
        cout << num1;
        switch (op) {
            case 1: cout << " + "; break;
            case 2: cout << " - "; break;
            case 3: cout << " * "; break;
            case 4: cout << " / "; break;
        }
        cout << num2 << " = " << fixed << setprecision(2) << result << endl;
    }
    return 0;
}